package com.xxx.controller;

import com.xxx.pojo.R;
import com.xxx.pojo.User;
import com.xxx.service.UserService;
import com.xxx.utils.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/8/26 9:35
 * @Copyright 博为峰
 */
//@RequestMapping("/login")//窄化
@Controller
public class LoginController {

    @Autowired
    private UserService userService;

    @ResponseBody
    @RequestMapping("/login")
    public R login(@RequestBody User user) {
        System.out.println("user = " + user);
        final User u = userService.queryUserByNamePwd(userService.queryUserByNamePwd(user));
        if (u == null)
            return new R(HttpStatus.NOT_FOUND.value(), null);
        return new R(HttpStatus.OK.value(), u);
    }
}
